SET NOCOUNT ON
SET QUOTED_IDENTIFIER ON
GO

PRINT '---- tblFields'

PRINT '-- Table title'

INSERT tblUFGTableTitles (utt_Tablename, utt_Languagename, utt_Title, utt_Description)
VALUES ('tblFields','Nederlands','Velden','Velden gegevens')

PRINT '-- Column titles'

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblFields','fld_ClubName','Nederlands','Clubnaam','U dient een clubnaam in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblFields','fld_ComplexName','Nederlands','Complex','U dient een complex in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblFields','fld_Field','Nederlands','Veld','U dient een veld in te vullen.')

INSERT tblUFGColumnTitles
(uct_TableName,uct_ColumnName,uct_Languagename,uct_Title,uct_SubTitle)
VALUES
('tblFields','fld_KindOfField','Nederlands','Veldsoort','U dient een veldsoort in te vullen.')

PRINT '-- Row Rights'

INSERT tblUFGRowRights
(urr_TableName,urr_RoleName,urr_SQLSelectExpression,urr_SQLInsertExpression,urr_SQLUpdateExpression,urr_SQLDeleteExpression)
VALUES
('tblFields','Wedstrijdsecretariaat Club',
'fld_ClubName = dbo.fnGetClubnameByUser(@UFGUsername)',
null,
'fld_ClubName = dbo.fnGetClubnameByUser(@UFGUsername)',
'fld_ClubName = dbo.fnGetClubnameByUser(@UFGUsername)')

UPDATE tblUFGForeignKeyColumns
SET ufc_AdditionalWhere = 'cpx_Clubname = dbo.fnGetClubnameByUser(@UFGUsername)'
WHERE ufc_ForeignKeyName = 'FK_fld_Clubname'
AND ufc_TableName = 'tblFields'
AND ufc_ColumnName = 'fld_Clubname'
AND ufc_ReferenceTableName = 'tblComplex'
AND ufc_ReferenceColumnName = 'cpx_Clubname'

PRINT '-- Display'
UPDATE tblUFGTables SET utb_DisplayInCategory = 'MAINTABLES' WHERE utb_TableName = 'tblFields'